﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for DonorClass
/// </summary>
public class DonorClass:BaseClass
{
    public static int AddDonor(Donor donor)
    {
        string insertSQL;
        insertSQL = "INSERT INTO DONORS (";
        insertSQL += " ID,NAME,GENDER,EMAIL,BIRTHDAY,JOB,PHONE,ADDRESS) ";
        insertSQL += "VALUES ('";
        insertSQL += donor.ID + "', '";
        insertSQL += donor._name + "', '";
        insertSQL += donor._gender + "', '";
        insertSQL += donor._email + "', '";
        insertSQL += donor._birthdate + "', '";
        insertSQL += donor._job + "', '";
        insertSQL += donor._phone + "', '";
        insertSQL += donor._address + "')";

        return RunDML(insertSQL);
     
    }
    public static int AddDonationProcss(DonationProcess d)
    {
        string insertprocess;
        //   d._barcode = donor._barcod;
        insertprocess = "INSERT INTO DONATIONPROCESS (";
        insertprocess += "BARCODE,FIRSTTIMETODONATE,DONATIONTYPE,dateOFLASTDONATION,ANYCOMPLICATIONS,PROBLEMINHEALTH ,TAKEVACCINATION,TRAVELEDABROAD,TREATMENT"+
        ",MEDICALOPERATION,BLOODTRANSFUSION,INFECTION,SPECIALFORWOMEN,TAKEDRUGSORALCOHOL,SEXRELATIONSHIP,CONTINUITYINDONATION,DISEASES,ID) ";
        insertprocess += "VALUES ('";
        insertprocess += d._barcode + "', '";
        insertprocess += d._firsttimedonate + "', '";
        insertprocess += d._donation_type + "', '";
        insertprocess += d._last_donation_date + "', '";
        insertprocess += d._complains + "', '";
        insertprocess += d._healthproblems + "', '";
        insertprocess += d._vacination + "', '";
        insertprocess += d._travel + "', '";
        insertprocess += d._tratment + "', '";
        insertprocess += d._medicaloperation + "', '";
        insertprocess += d._blood_transfusion + "', '";
        insertprocess += d._infection + "', '";
        insertprocess += d._pregnance + "', '";
        insertprocess += d._take_drugs + "', '";
        insertprocess += d._do_sex + "', '";
        insertprocess += d._contenous_donation + "', '";
        insertprocess += d._anydesiease + "', '";
         insertprocess += d.ID + "')";
        return RunDML(insertprocess);
    }
    public static DataTable SearchDonor(string Field,string Value)
    {
        string query = String.Format("select * from DONORS where {0} like '%{1}%'", Field, Value);
        return RunSelect(query);
    }
    //public static int UpdateDonor(Donor donor)
    //{
    //    string query = "";
    //    return RunDML(query);
    //}
    //public int updateDonationProcess(Donor donor)
    //{
    //    string query = "";
    //    return RunDML(query);
    //}
    public static int AddComp_Donor(string ID,string Code)
    {
        string query =String.Format("insert into COMP_DONORS values('{0}','{1}')",ID,Code);
       return RunDML(query);
    }
    public static int checkState(string[] confirm)
    {
        string up = "update DONATIONPROCESS set HEMOGLOBINRATIO='" + confirm[0] + "', PRESSURE ='" + confirm[1] + "', NUMDEROFBEAT ='" + confirm[2] + "' , TOPPLINGOFBEAT='" + confirm[3] + "',WEIGHT='" + confirm[4] + "',LENGTH='" + confirm[5] + "'  where BARCODE='" + confirm[6] + "'";
        return RunDML(up);
    }
    public static int final_Update(string [] fupdate)
    {
        string f_update = "update DONATIONPROCESS set COMPETENTSIGNATURE='" + fupdate[0] + "', DOCTORSIGNATURE ='" + fupdate[1] + "', STATUS ='" + fupdate[2] + "'  where BARCODE='" + fupdate[3] + "'";
        return RunDML(f_update);
    }

    
}